home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Programming Languages Suite
/
ProgramD2.iso
/
Visual Database
/
Visual dBase v5.5
/
CBTSAMP.PAK
/
CUSTOMER.MNU
< prev
next >
Wrap
Text File
|
1995-07-18
|
9KB
|
259 lines
******************************************************************************
* PROGRAM: Customer.mnu
*
* WRITTEN BY: Borland Samples Group
*
* DATE: 12/93
*
* UPDATED: 6/95
*
* REVISION: $Revision: 1.55 $
*
* VERSION: Visual dBASE
*
* DESCRIPTION: This menu file is used by Customer.wfm for performing simple
* tasks. It allows adding, deleting, and searching for
* customers, brings up the orders form for a customer,
* and runs reports.
*
* PARAMETERS: FormObj -- the form to which this menu is attached.
*
* CALLS: None
*
* USAGE: form.menuFile = "Customer.mnu"
*
*******************************************************************************
#include <Messdlg.h>
** END HEADER -- do not remove this line*
* Generated on 06/21/94
*
Parameter FormObj
NEW CUSTOMERMENU(FormObj,"Root")
CLASS CUSTOMERMENU(FormObj,Name) OF MENUBAR(FormObj,Name)
this.Text = ""
this.OnInit = {;set procedure to &_dbwinhome.samples\Sampproc.prg}
DEFINE MENU FILE OF THIS;
PROPERTY;
Text "&File"
DEFINE MENU EXIT OF THIS.FILE;
PROPERTY;
OnClick CLASS::ONEXIT,;
Text "E&xit",;
StatusMessage "Leave Customer form."
DEFINE MENU CUSTOMER OF THIS;
PROPERTY;
Text "&Customer"
DEFINE MENU VIEWEDIT OF THIS.CUSTOMER;
PROPERTY;
OnClick CLASS::VIEWEDITONCLICK,;
Text "&Edit",;
Shortcut "Ctrl-E",;
StatusMessage "Edit data."
DEFINE MENU SEPARATOR1 OF THIS.CUSTOMER;
PROPERTY;
Separator .T.,;
Text ""
DEFINE MENU ADD OF THIS.CUSTOMER;
PROPERTY;
OnClick CLASS::ADDONCLICK,;
Text "&Add",;
Shortcut "Ctrl-A",;
Enabled .T.,;
StatusMessage "Add a new customer."
DEFINE MENU DELETE OF THIS.CUSTOMER;
PROPERTY;
OnClick CLASS::DELETEONCLICK,;
Text "&Delete",;
Shortcut "Ctrl-D",;
Enabled .F.,;
StatusMessage "Delete the current customer."
DEFINE MENU SEPARATOR2 OF THIS.CUSTOMER;
PROPERTY;
Separator .T.,;
Text ""
DEFINE MENU SEARCH OF THIS.CUSTOMER;
PROPERTY;
OnClick CLASS::SEARCHONCLICK,;
Text "&Search ...",;
Shortcut "Ctrl-S",;
StatusMessage "Search for a customer."
DEFINE MENU SEPARATOR3 OF THIS.CUSTOMER;
PROPERTY;
Separator .T.,;
Text ""
DEFINE MENU CURRENT_ORDERS OF THIS.CUSTOMER;
PROPERTY;
OnClick CLASS::CURRENTORDERSONCLICK,;
Text "&Orders ...",;
Shortcut "Ctrl-O",;
StatusMessage "See the orders for the current customer in the Orders form."
DEFINE MENU REPORT OF THIS;
PROPERTY;
Text "&Report"
DEFINE MENU CUSTOMER_REPORT OF THIS.REPORT;
PROPERTY;
OnClick {;create session ;set lock off ;report form customer},;
Text "Customer &Report",;
Shortcut "Ctrl-R",;
StatusMessage "Display a report of customer information."
DEFINE MENU CUSTOMER_LABELS OF THIS.REPORT;
PROPERTY;
OnClick {;create session ;set lock off ;report form customer.rpl},;
Text "Customer &Labels",;
Shortcut "Ctrl-L",;
StatusMessage "Display labels for all customers."
****************************************************************************
procedure SearchOnClick
* Bring up Search.wfm modally.
****************************************************************************
private searchForm, searchItem, saveRec
if reccount() = 0 && If table is empty, don't search
InformationMessage("This table is empty.", "Oops")
else
form.CheckChanged(.T.)
set procedure to &_dbwinhome.samples\Search.wfm additive
searchForm = new SearchForm()
searchForm.keyName = "Name" && Indicate to user expression to enter
searchForm.formatting = "@X"
searchForm.mdi = .F. && Necessary for a modal form
searchItem = searchForm.Readmodal()
if type("searchItem") = "O" .and. searchItem.id <> 0;
.and. .not. empty(searchForm.value)
*** If Cancel or ESC wasn't used to exit Search.wfm
saveRec = recno()
form.enabled = .F.
seek upper(ltrim(rtrim(searchForm.value)))
if .not. found()
InformationMessage(FormatStr("Customer %1 \n Was not Found.",;
searchForm.value),;
"Info")
if saveRec <= reccount() && If weren't at eof(), go to saveRec
go saveRec
else
go bottom
endif
endif
form.enabled = .T.
endif
searchForm.Release()
close procedure &_dbwinhome.samples\Search.wfm
endif
****************************************************************************
procedure DeleteOnClick
* Delete current record.
****************************************************************************
if ConfirmationMessage("Are you sure you want to delete this customer?",;
"Confirm") = YES
delete && Deleted is on, so deleted records are there until you PACK
commit()
form.changesMade = .F.
begintrans()
if type("form.nextCustButton") <> "U"
form.nextCustButton.OnClick() && Move to next record (customer.wfm)
else
form.vcrNextButton.OnClick() && Move to next record (custord.wfm)
endif
endif
****************************************************************************
procedure AddOnClick
* Add new record.
****************************************************************************
private addForm, custNoField, newCustomer, inEditMode
form.CheckChanged(.T.)
if ConfirmationMessage("Are you sure you want to add a customer?",;
"Confirmation") = YES
* If running from Custord.wfm, use form.curPage.inEditMode,
* otherwise, if from customer.wfm/orders.wfm, use form.inEditMode
inEditMode = iif(type("form.curPage") <> "U", form.curPage.inEditMode,;
form.inEditMode)
if .not. inEditMode
form.ViewEdit() && Make sure record is editable
else
form.nameEntry.SetFocus()
endif && and begin a transaction
form.changesMade = .T. && Since we are adding a record
form.previousRecord = recno()
append blank && This must be done after begintrans()
custNoField = field(1) && so rollback() could delete if necessary
newCustomer = str(val(form.maxCustNo) + 1, 4)
replace &custNoField with newCustomer && New customer number
form.maxCustNo = newCustomer
endif
****************************************************************************
procedure CurrentOrdersOnclick
* Show orders for current customer by bringing up Orders.wfm
****************************************************************************
form.CheckChanged(.T.)
if type ("form.parentOrdersForm") = "U"
if type ("form.childOrdersForm") = "U"
form.StartOrdersForm()
form.CallShowOrders(customer->customer_n)
else
form.CallShowOrders(customer->customer_n)
form.childOrdersForm.open()
form.childOrdersForm.windowState = 0
form.childOrdersForm.windowState = 0
form.childOrdersForm.setFocus()
endif
else
form.parentOrdersForm.setFocus()
endif
****************************************************************************
procedure ViewEditOnClick
* Toggle View/Edit modes.
****************************************************************************
form.ViewEdit()
****************************************************************************
procedure OnExit
* Clean up.
****************************************************************************
if type ("form.parentOrdersForm") <> "U"
* Release parent orders form, which releases this child
form.parentOrdersForm.Release()
else
form.Release()
endif
ENDCLASS